package top.kaoshanji.p1ch02a;

import org.apache.hc.core5.http.ContentType;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 代码清单-p1ch02a-34页a：打印"Hello World"的Servlet
 * URL访问地址：/hi
 * @author kaoshanji
 * ^_^
 * create time 2025/4/1 20:14
 */
public class HelloWorld extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // resp.setContentType("text/html");
        // resp.setCharacterEncoding("UTF-8");

        resp.setContentType(ContentType.TEXT_HTML.toString());

        PrintWriter out = resp.getWriter();

        out.println("<HTML>");
        out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");
        out.println("<BODY>");
        out.println("<BIG>我是靓仔1号</BIG>");
        out.println("</BODY></HTML>");

    }

}
